<template>
  <el-dialog title="登录界面" :visible.sync="dialogFormVisible" width="80%" :close-on-click-modal="false">
    <el-form :model="form">
      <el-form-item label="账号：">
        <el-input placeholder="请输入账号" type="text" v-model="form.username" maxlength="20" show-word-limit></el-input>
      </el-form-item>
      <el-form-item label="密码：">
        <el-input placeholder="请输入密码" v-model="form.password"  maxlength="20" show-password></el-input>
      </el-form-item>
      <div style="margin-top: 20px;text-align: right">
        <el-radio-group v-model="radio3" size="small">
          <el-radio-button label="记住我"></el-radio-button>
          <el-radio-button label="不要"></el-radio-button>
        </el-radio-group>
      </div>
    </el-form>
    <div style="margin-top: 20px;text-align: right">
      <button class="cancelcss" @click="dialogFormVisible = false">取 消</button>
      <button class="logincss" @click="userlogin">登 录</button>
    </div>
  </el-dialog>
</template>

<script>
//登录页面
export default {
  name: "LoginModules",
  data() {
    return {
      dialogFormVisible: false,
      form: {
        username: '',
        password: '',
      },
      formLabelWidth: '120px',
      radio3: '不要'
    }
  },
  methods: {
    singshow(){
      this.dialogFormVisible = true
    },
    userlogin(){
      if(this.form.username.trim().length <= 0 && this.form.password.trim().length <= 0){
        this.$CustomMessage_WAENING('提示','请填写完整！');
        return;
      }
      this.axios.post(this.Global.BASE_URL+'/login/ReturnUserName',
        {username:this.form.username,password:this.form.password,radio3:(this.radio3=='不要'?0:1)}).then((res)=>{
        if(res.data != null){
          if("1000" == res.data.msg) this.$CustomMessage_WAENING('提示','请填写完整！');
          if("3000" == res.data.msg) this.$CustomMessage_WAENING('提示','账号密码错误');
          if("2000" == res.data.msg){
            this.$emit("UserName",res.data.data);
            this.dialogFormVisible = false;
          }
        }
      }).catch(erroe=>{
        this.$CustomMessage_ERROR('错误','用户信息错误！');
      })
    }
  }
}
</script>

<style scoped>
.cancelcss{
  border: 1px solid #e5e9f2;
  border-radius: 7px;
  padding: 10px 15px;
  outline: none;
}
.logincss{
  border: 1px solid #e5e9f2;
  border-radius: 7px;
  padding: 10px 15px;
  background: #409EFF;
  color: white;
  outline: none;
}
</style>
